//
//  GoodsDetailController.m
//  MindBox
//
//  Created by MS on 16-1-4.
//  Copyright (c) 2016年 Lemon. All rights reserved.
//

#import "GoodsDetailController.h"

@interface GoodsDetailController ()<UIWebViewDelegate>

@end

@implementation GoodsDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor =[UIColor whiteColor];
    
    [self setNavBar];
    
    [self loadwebView];

}

-(void) loadwebView
{
    UIWebView * webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 64, WIDTH, HIGHT-64)];
    webView.backgroundColor =[UIColor colorWithRed:0.97f green:0.97f blue:0.97f alpha:1.00f];

    [self.view addSubview:webView];
    webView.scalesPageToFit = YES;
    webView.scrollView.bounces = NO;
//    webView.scrollView.alwaysBounceVertical = YES;
    
    self.webView = webView;
    webView.delegate = self;
    
    if (self.urlStr) {
        [self loadNewDataWithUrlStr:self.urlStr];
    }

//    if (self.goodsData.html_src) {
//        [self loadNewDataWithUrlStr:_goodsData.html_src];
//    }
}

-(void)loadNewDataWithUrlStr:(NSString *)UrlStr
{
    NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:UrlStr]];
    [self.webView loadRequest:request];
    
}


-(void)setNavBar
{
    MyNavigationItem * leftItem = [MyNavigationItem navigationItemWithImage:@"ic_bg_white_arrow_left" andHighlightImage:@"ic_bg_white_arrow_left" andTag:0 andTitle:nil addTarget:self action:@selector(leftBtnClick)];
    
    MyNavigationItem * rightItem =[MyNavigationItem navigationItemWithImage:@"ic_bg_white_more" andHighlightImage:@"ic_bg_white_more" andTag:0 andTitle:nil addTarget:self action:@selector(rightClick)];
    MyNavigationBar * navBar = [[MyNavigationBar alloc]initWithFrame:CGRectMake(0, 20, self.view.width, 44)];
    self.navBar = navBar;
    
    UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(0, navBar.frame.size.height-0.5, navBar.frame.size.width, 0.5)];
    lineView.backgroundColor =[UIColor grayColor];
    [navBar addSubview:lineView];
    
    [navBar setNavigationBarWithBgImageName:@"无" andTitle:nil  andTitleView:nil andLeftItems:@[leftItem] andRightItems:@[rightItem]];
    [self.view addSubview:navBar];
    
}

-(void)leftBtnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)rightClick
{
    
}

-(void)webViewDidStartLoad:(UIWebView *)webView
{
    
    
}
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
//    NSString *title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
   
    
}



-(void)dealloc
{
//    NSLog(@"WebView--Controller卸载");
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
